package com.MyBatis.test_1_28_mybatis.mapper;

import com.MyBatis.test_1_28_mybatis.model.ArticleInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ArticleInfoMapper {
    @Select("select * from articleinfo where id = #{articleId}")
    ArticleInfo selectById(Integer articleId);

    /**
     * 多表查询
     * @param articleId
     * @return
     */
    @Select("SELECT ta.*,tb.username,tb.age FROM `articleinfo` ta " +
            "LEFT JOIN userinfo tb on ta.id = tb.id " +
            "where ta.id = 1") // 一定要注意前后是否有空格 , 不管怎么写 MyBatis 会自动的帮你完成映射
    ArticleInfo selectArcAndUserById(Integer articleId);
}
